package util;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by Administrator on 2016/4/24.
 */
public class HttpUtil {

    public HttpUtil() {
    }

    public static InputStream getXml(String path) {
        InputStream inputStream = null;
        try {
            URL url = new URL(path);
            if (url != null) {
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setConnectTimeout(3000);
                conn.setDoInput(true);
                conn.setRequestMethod("GET");
                int code = conn.getResponseCode();
                if (code == 200) {
                    inputStream = conn.getInputStream();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return inputStream;
    }
}
